import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import rollupPluginImage from '@rollup/plugin-image'
import path from 'path'
// import { VantResolver } from '@vant/auto-import-resolver';

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    host: '127.0.0.1',
    proxy: {
      '/api': {
        target: 'http://localhost:8090',
        changeOrigin: true,
        secure: false,
        // 如需传递Cookie需要添加以下配置
        headers: {
          Connection: 'keep-alive'
        }
      }
    }
  },
  build: {
    outDir: 'dist',
    assetsDir: 'static',
  },
  plugins: [
    vue(),
    Components({
      resolvers: [],
    }),
    rollupPluginImage({
      include: ['**/*.png', '**/*.jpg', '**/*.jpeg', '**/*.gif', '**/*.svg'], // 图片文件匹配规则
      // output: 'static/img/[name].[hash:8].[ext]', // 输出文件命名规则
    }),
  ],
  resolve: {
    alias: {
      "@": path.resolve("./src") // 相对路径别名配置，使用 @ 代替 src
    }
  }
})
